owner = msg.sender;
}
function calculate(uint a, uint b) public pure
returns(uint) {
return a*b;
}
function destroyContract() public {
if (msg.sender == owner) {
selfdestruct(owner);
}
}
}
After running the destroyContract function once, the calculatation
would not work again.
2.5.23 Lab 1
Now that we have learnt most of the features of Solidity, the following
is a sample code that you can run to know how the students can
enroll to a program with a Solidity smart contract:
// SPDX-License-Identifier: SOME IDENTIFIER
pragma solidity ^0.8.10;
contract StudentEnrollmentContract {
address private owner;
Student[] private students;
uint private latestEnrollmentNumber;
struct Student {
string name; // short name
string dob; // date of birth in ddMMyyyy format
string grade; //score assigned to student
uint enrollmentNumber; // enrollmentNumber that keeps on
increasing with each new student
}